package com.huhu.sys.es;

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;

/**
 * Created by Tremain on 2016/10/27.
 */
public class ElasticFactory {

    private static ElasticFactory instance;

    public ElasticFactory getInstance() {

        if (instance == null) {
            synchronized (ElasticFactory.class) {
                instance = new ElasticFactory();
            }
        }

        return instance;
    }

    public Client createESClient(String index, String type) {
        Client client = null;

        try {
            Settings settings = Settings.settingsBuilder()
                    .put("client.transport.ignore_cluster_name", true)
                    .put("client.transport.sniff", true).build();
//            client = new TransportClient(settings)
//                    .addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }

}
